<template>
		<!--判断是否是标签节点-->
	<block v-if="node.node == 'element'">
		<!--button类型-->
		<button v-if="node.tag == 'button'" type="default" size="mini" :class="node.classStr" :style="node.styleStr">
			<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" />
		</button>
		
		<!--a类型-->
		<view v-else-if="node.tag == 'a'" @click="wxParseATap(node.attr,$event)" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr" style="display: inline; border-bottom: 1px solid #555555;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl"  :avatarurl2="avatarurl2" />
			</block>
		</view>
		
		<!--li类型-->
		<view v-else-if="node.tag == 'li'" :class="node.classStr" :style="node.styleStr">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" />
			</block>
		</view>
		
		<!--table类型-->
		<wx-parse-table v-else-if="node.tag == 'table'" :class="node.classStr" :style="node.styleStr" :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2"/>
		
		<!--br类型-->
		<!-- #ifndef H5 -->
			<text v-else-if="node.tag == 'br'">\n</text>
		<!-- #endif -->
		<!-- #ifdef H5 -->
			<br v-else-if="node.tag == 'br'">
		<!-- #endif -->
		
		<!--video类型-->
		<wx-parse-video :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" v-else-if="node.tag == 'video'"/>
	
		<!--audio类型-->
		<wx-parse-audio :node="node"  :avatarurl="avatarurl"  :avatarurl2="avatarurl2" v-else-if="node.tag == 'audio'"/>
	
		<!--img类型-->
		<wx-parse-img :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" v-else-if="node.tag == 'img'" :style="node.styleStr"/>
		
		<!--strong标签-->
		<view v-else-if="node.tag == 'strong'" :class="node.classStr" :style="node.styleStr" style="font-weight: 700;display: inline;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2"/>
				
			</block>
		</view>
		<!--span标签-->
		<view v-else-if="node.tag == 'span'" :class="node.classStr"  :style="node.styleStr" style="display: inline;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" />
				
			</block>
		</view>
		<!--em标签-->
		<view v-else-if="node.tag == 'em'" :class="node.classStr"  :style="node.styleStr" style="display: inline;font-style: italic;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" />
			</block>
		</view>
	
		<!--其他标签-->
		<view v-else :class="node.classStr" :style="node.styleStr">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" />
				
			</block>
		</view>
	</block>
	
	<!--判断是否是文本节点-->
	<!--判断是否是文本节点-->
  <block v-else-if="node.node == 'text'">
    <view v-if="node.text == '#@nickname@#'">
	  <view class="nicknameinfo">
      {{nickname}}4
	  </view>
    </view>
    <view v-else-if="node.text == '#@nickavatar@#'" class="userinfo">
	  <image class='avatarpic' :src='avatarurl'></image>
      <view class="userinfo-avatar">       
        <open-data  type="userAvatarUrl"></open-data>
      </view>
    </view>
    <view v-else-if="node.text == '#@nickavatar2@#'" class="userinfo">
		image class='avatarpic' :src='avatarurl2'></image>
      <view class="userinfo-avatar">
        
        <open-data  type="userAvatarUrl"></open-data>

      </view>
    </view>
    <view v-else>
      {{node.text}}
    </view>
  </block>
</template>


<script>
	import wxParseTemplate from './wxParseTemplate5';
	//import wxParseImg from './wxParseImg';
	import wxParseVideo from './wxParseVideo';
	import wxParseAudio from './wxParseAudio';
	import wxParseTable from './wxParseTable';
	
	export default {
		name: 'wxParseTemplate4',
		props: {
			node: {},
      avatarurl:{},
      avatarurl2:{},
	  nickname:'444'
		},
		components: {
			wxParseTemplate,
			//wxParseImg,
			wxParseVideo,
			wxParseAudio,
			wxParseTable
		},

		methods: {

			wxParseATap(attr,e) {
				const {
					href
				} = e.currentTarget.dataset;
				if (!href) return;
				let parent = this.$parent;
				while(!parent.preview || typeof parent.preview !== 'function') {
					parent = parent.$parent;
				}
				parent.navigate(href, e, attr);
			},


		}
	};
</script>
<style>
	  .userinfo-avatar {
	    overflow:hidden;
	    display: block;
	    width: 160rpx;
	    height: 160rpx;  
	   
	    border-radius: 50%;
	    border: 2px solid #fff;
	    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
		margin:auto;
	  }
	  .userinfo {	  
	    color: #fff;
	 
	   
	    
	  }

    .avatarpic{
      margin:auto;
      width: 180px;
      height: 180px;
      position: relative;
      margin-bottom: -160px;
    }


.nicknameinfo{
	margin-top:90px;
}





</style>
